**************************************************
* This program performs the additional analyses  *
* on joint venture & strategic alliance activity *
* reported in Table B2                           *
**************************************************

	use "C:\cow\comp_jvsa.dta",clear

	*Convert strings to numerics
	destring gvkey, gen(firm)	
	encode state, gen(lstateFE)
	encode incorp, gen(istateFE)
	encode port, gen(ffFE)

	*Set timeframe 
	drop if fyear < 1996

	*Drop if missing industry
	rename sic sic4
	gen sic3 = floor(sic4/10)
	gen sic1 = floor(sic4/1000)
	drop if missing(sic4)
	*Drop utilities
	drop if sic4 >= 4900 & sic4 <= 4999
	*Drop financials
	drop if sic4 >= 6000 & sic4 <= 6999
	*Drop public administration/non-classifiable firms
	drop if sic4 >= 9000 & sic4 <= 9999

	*Drop if missing headquarter state
	drop if missing(state)
	*Drop if missing state of incorporation
	drop if missing(incorp)
	*Drop if not incorporated in U.S. state
	drop if inlist(incorp, "AS", "INTL", "PR", "TT", "VI")

	

	local statelist "DE OK MO KS TX NV NJ MD WA"
	gen treatment = 0
	foreach state of local statelist {
			replace treatment = 1 if incorp == "`state'"
	}

	*Create macros for date when law was passed
		local DE_cow = date("01Jul2000","DMY")
		local OK_cow = date("01Nov2001","DMY")
		local MO_cow = date("01Oct2003","DMY")
		local KS_cow = date("01Jan2005","DMY")
		local TX_cow = date("01Jan2006","DMY")
		local NV_cow = date("01Oct2007","DMY")
		local NJ_cow = date("11Mar2011","DMY")
		local MD_cow = date("01Oct2014","DMY")
		local WA_cow = date("01Jan2016","DMY")
		
		* adjust calendar year of fyeendt to be next year if fyenddt month < cow law date
		gen ayear = year(datadate)
		local statelist "DE OK MO KS TX NV NJ MD WA"
		foreach state of local statelist {
				replace ayear = year(datadate)-1 if incorp == "`state'" & month(datadate) < month(``state'_cow')
				}

		*cow: indicator equal to one if firm is incorporated in a state that has passed a COW law
		gen cow = 0
		local statelist "DE OK MO KS TX NV NJ MD WA"
		foreach state of local statelist {
				replace cow = 1 if incorp == "`state'" & ayear >= year(``state'_cow')
				}
				
		local indep "mveq_rd mktcap assets assetsm lvm lvb mb leverage q illiq roa"
		foreach v of local indep {
			replace `v'=0 if missing(`v')
					gen ln_`v' = log(1+`v')

		}				

************************
* Table B2 Regressions *
************************
		
		reghdfe d_jvsa cow , absorb(firm lstate#fyear sic3#fyear) vce(cluster istate)
		reghdfe d_jvsa cow ln_mveq_rd leverage mb illiq roa , absorb(firm lstate#fyear sic3#fyear) vce(cluster istate)

		
